package org.example;
import org.example.config.SpringConfig;
import org.example.service.TaskService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.util.concurrent.TimeUnit;
public class App {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);
        TaskService taskService = context.getBean(TaskService.class);
        taskService.submitTimePrintTask("时间打印任务1");
        taskService.submitCountdownTask("倒计时任务1", 5);
        taskService.submitTimePrintTask("时间打印任务2");

        try {
            TimeUnit.SECONDS.sleep(9);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        taskService.shutdownExecutor();
        context.close();
    }
}
